import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-02-07
 * Time: 22:05
 */
class Student {
    public int age;
    public String name;

    Student(String name,int age){
        this.name = name;
        this.age = age;
    }
}

public class Test {
     public static void main(String[] args) {
         List<Integer> list = new ArrayList<>();
         list.add(1);
         list.add(3);
         list.add(7);
         Queue<Integer> priorityQueue3 = new PriorityQueue<>(list);

         Queue<Integer> priorityQueue1 = new PriorityQueue<>();//底层是堆
         Queue<Student> priorityQueue2 = new PriorityQueue<>();//底层是堆

         priorityQueue1.offer(10);
         priorityQueue1.offer((2));
         System.out.println(priorityQueue1.poll());
         //故是小根堆，弹出顶元素

         priorityQueue2.offer(new Student("张三",12));
         //priorityQueue2.offer(new Student("哈哈",23));
         //此时添加这个代码会报错，因为不能添加不能比较的对象
         //priorityQueue2.offer(null);
         //不能插入null会抛出空指针异常



    }

    public static void main1(String[] args) {
        Heap testHeap = new Heap();
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        testHeap.initElem(array);
        testHeap.createHeap1();
        System.out.println();
        testHeap.createHeap2();
        testHeap.offer(80);
        System.out.println();
        testHeap.pop();
        System.out.println();
    }
}
